package com.kancy.spring.sample.event;

import com.kancy.spring.context.annotation.Async;
import com.kancy.spring.context.annotation.Bean;
import com.kancy.spring.context.annotation.Component;
import com.kancy.spring.context.event.ApplicationEvent;
import com.kancy.spring.context.event.ApplicationListener;
import com.kancy.spring.log.Log;

import java.util.concurrent.Executor;
import java.util.concurrent.Executors;

/**
 * SimpleApplicationListener
 *
 * @author kancy
 * @date 2020/2/18 12:19
 */
@Component
public class SimpleApplicationListener implements ApplicationListener<ApplicationEvent> {
    /**
     * 处理事件
     * @param event
     */
    @Async
    @Override
    public void onApplicationEvent(ApplicationEvent event) {
        Log.info(event.getSource().toString());
    }

    //@Bean
    public Executor taskExecutor(){
        return Executors.newFixedThreadPool(10);
    }
}
